package com.yixin.entity;

import lombok.Data;

/**
 * 后端统一返回结果类
 * */
@Data
public class Result {
    private Integer code; // 200成功，500失败
    private String message;
    private Object data;

    private Result() {
    }

    public static Result success() {
        Result result = new Result();
        result.code = 200;
        result.message = "success";
        return result;
    }

    public static Result success(Object data) {
        Result result = new Result();
        result.code = 200;
        result.message = "success";
        result.data = data;
        return result;
    }

    public static Result error(String message) {
        Result result = new Result();
        result.code = 500;
        result.message = message;
        return result;
    }
}
